﻿CREATE TABLE [dbo].[UserApplication] (
    [UserApplicationId]		INT           IDENTITY (1, 1) NOT NULL,
    [ApplicationId]			INT NOT NULL,      
    [UserId]				INT NOT NULL,      
    [adt_DateCreated]		DATETIME      NOT NULL DEFAULT getdate(),
    [adt_CreatedBy]			VARCHAR (50)  NULL,
    CONSTRAINT [PK_UserApplication] PRIMARY KEY CLUSTERED ([UserApplicationId] ASC),
    CONSTRAINT [FK_UserApplication_ToTable1] FOREIGN KEY ([ApplicationId]) REFERENCES [Application]([ApplicationId]),
    CONSTRAINT [FK_UserApplication_ToTable2] FOREIGN KEY ([UserId]) REFERENCES EnterpriseUser([UserId])

);




GO

CREATE UNIQUE INDEX [IX_UserApplication_Column] ON [dbo].[UserApplication] ([UserId], [ApplicationId])
